package common.sort;

import common.util.ArrayUtil;

import java.util.Arrays;

public abstract class AbstractSort implements ISort {


    public void check() {
        int count = 100;
        int fail = 0;
        for (int i = 0; i < count; i++) {
            int[] instant = ArrayUtil.instantRandom(100, 100);
            int[] copy = ArrayUtil.copy(instant);
            sort(copy);
            int[] base = ArrayUtil.copy(instant);
            Arrays.sort(base);
            if (!ArrayUtil.compare(base, copy)) {
                System.out.println("对数失败");
                System.out.println("原始数组：" + Arrays.toString(instant));
                System.out.println("当前排序：" + Arrays.toString(copy));
                System.out.println("对数排序：" + Arrays.toString(base));
                fail++;
            }
        }
        if (fail == 0) {
            System.out.println("对数成功");
        }
    }
}
